From 5224835c7ee35da7c72198bf16ede3beee920c87 Mon Sep 17 00:00:00 2001 From: parkrrrr Date: Wed, 15 Oct 2003 16:31:32 +0000 Subject: [PATCH] Same change as the previous one for Cetus. These crashes haven't been reported, but they could have happened under the same circumstances. Well, except for the ifdefed-out code in mapopolis, which is included for completeness. --- magnav.c | 5 +++-- magproto.c | 14 ++++++++++---- mapopolis.c | 5 +++-- 3 files changed, 16 insertions(+), 8 deletions(-) diff --git a/magnav.c b/magnav.c index 269c1313d..f7c13815e 100644 --- a/magnav.c +++ b/magnav.c @@ -155,11 +155,12 @@ my_writewpt(const waypoint *wpt) wpt->shortname; rec = xcalloc(sizeof(*rec)+56,1); - + + tm = NULL; if ( wpt->creation_time ) { tm = gmtime( &wpt->creation_time); } - else { + if ( !tm ) { time( &tm_t ); tm = gmtime( &tm_t ); } diff --git a/magproto.c b/magproto.c index 4f19669e9..3ed780db5 100644 --- a/magproto.c +++ b/magproto.c @@ -1203,12 +1203,18 @@ void mag_track_disp(const waypoint *waypointp) ilat = waypointp->position.latitude.degrees; ilon = waypointp->position.longitude.degrees; + tm = NULL; if (waypointp->creation_time) { tm = gmtime(&waypointp->creation_time); - hms = tm->tm_hour * 10000 + tm->tm_min * 100 + tm->tm_sec; - date = tm->tm_mday * 10000 + tm->tm_mon * 100 + tm->tm_year; - fracsec = waypointp->centiseconds; - } else { + if ( tm ) { + hms = tm->tm_hour * 10000 + tm->tm_min * 100 + + tm->tm_sec; + date = tm->tm_mday * 10000 + tm->tm_mon * 100 + + tm->tm_year; + fracsec = waypointp->centiseconds; + } + } + if (!tm) { date = 0; fracsec = 0; } diff --git a/mapopolis.c b/mapopolis.c index a6bf20e0f..2cf8f9a99 100644 --- a/mapopolis.c +++ b/mapopolis.c @@ -200,11 +200,12 @@ my_writewpt(const waypoint *wpt) wpt->shortname; rec = xcalloc(sizeof(*rec)+56,1); - + + tm = NULL; if ( wpt->creation_time ) { tm = gmtime( &wpt->creation_time); } - else { + if ( !tm ) { time( &tm_t ); tm = gmtime( &tm_t ); } -- 2.30.2